home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9525 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: tank.news.pipex.net!pipex!warwick!bsmail!talisker!nathan
  3. From: nathan@pact.srf.ac.uk (Nathan Sidwell)
  4. Subject: Re: Borland sqrt() bug?
  5. Message-ID: <Do3wzC.Fyw@uns.bris.ac.uk>
  6. Sender: usenet@uns.bris.ac.uk (Usenet news owner)
  7. Nntp-Posting-Host: talisker.pact.srf.ac.uk
  8. Organization: Inmos
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. References: <4hotp5$a1h@news.hk.linkage.net> <3140A7EE.1DA3@hsc.unt.edu>
  11. Date: Mon, 11 Mar 1996 14:16:24 GMT
  12.  
  13. Steve Fogoros (sfogoros@hsc.unt.edu) wrote:
  14. : Priscilla Ngie wrote:
  15. : > 
  16. : > I tired the following code
  17. : > 
  18. : >         float num;
  19. : >         if (num > 0) sqrt(num);
  20. : > 
  21. : > and Borland C++ 4.02 returns me with an error
  22. : > 
  23. : >         sqrt: DOMAIN error
  24. : > 
  25. : > This error dialog box only pops up when num is a +ve number approaching
  26. : > zero, eg 0.000000005.
  27. : > 
  28.  
  29. : sqrt() takes a double as its argument and returns a double. Declare num 
  30. : as double or cast it to double.
  31.  
  32. How will this change things? [If a prototype is in scope, floats will
  33. be promoted to doubles.   If a prototype is not in scope, floats will
  34. be promoted to doubles.]
  35.  
  36. sqrt is well defined for all positive values as well as both IEEE zeroes.
  37.  
  38. nathan
  39. --
  40. Nathan Sidwell                         Holder of the Xmris home page
  41. Chameleon Architecture Group at SGS-Thomson, formerly Inmos
  42. http://www.pact.srf.ac.uk/~nathan/                  Tel 0117 9707182
  43. nathan@inmos.co.uk or nathan@bristol.st.com or nathan@pact.srf.ac.uk
  44.